package com.ems.sys.dao;

import com.ems.sys.pojo.*;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/****
 * @Author:传智播客
 * @Description:Emlpoyee的Dao
 * @Date 2019/6/14 0:12
 *****/
public interface EmployeeMapper extends Mapper<Employee> {
    @Select("select * from employee")
    @Results({
            @Result(id=true ,column = "eId",property = "eId"),
            @Result(column = "dNum",property = "dNum"),
            @Result(column = "pNum",property = "pNum"),
            @Result(column = "eName",property = "eName"),
            @Result(column = "card",property = "card"),
            @Result(column = "birthday",property = "birthday"),
            @Result(column = "sex",property = "sex"),
            @Result(column = "phone",property = "phone"),
            @Result(
                    property = "department",
                    column = "dNum",
                    javaType = Department.class,
                    many = @Many(select = "com.ems.sys.dao.DepartmentMapper.selectByPrimaryKey")
            ),
            @Result(
                    property = "position",
                    column = "pNum",
                    javaType = Position.class,
                    many = @Many(select = "com.ems.sys.dao.PositionMapper.selectByPrimaryKey")
            )

    })
    List<Employee> findByEId();
}
